import { ItemTooltip } from "../ItemTooltip";
import { ItemData } from "../../../../resource/info/ItemData";
import { RuneSWallowedEffects } from "./RuneSWallowedEffects";
import { SecondCareerHolyRuneSubTips } from "./SecondCareerHolyRuneSubTips";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { DisplayUtil } from "../../../../../common/DisplayUtil";
import { ItemsUtil } from "../../../shortcuts/item/ItemsUtil";
import { Language } from "../../../../../../extend/language/Language";
import { ToolTipUtil } from "../util/ToolTipUtil";
import { ECategory } from "../../../../../../Message/Public/ECategory";
import { ObjCreate } from "../../ObjCreate";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { GameDefConfig } from "../../../../resource/GameDefConfig";
import { Cache } from "../../../../cache/Cache";
import { ECareer } from "../../../../../../Message/Public/ECareer";
import { RuneToolTipUtil } from "./RuneToolTipUtil";
import { SecondCareerUtil } from "../../../secondCareer/util/SecondCareerUtil";
import { EProp } from "../../../../../../Message/Public/EProp";
import { HTMLUtil } from "../../../../../../com/gengine/utils/HTMLUtil";
//class HolyRuneToolTip
    
    export  class HolyRuneToolTip extends ItemTooltip
    {
        constructor(arg1: ItemData=null)
        {
            super(arg1);
            this._effectsContainer = new Object /* flash.display.Sprite */();
            this._swallowEffect = new RuneSWallowedEffects();
            this._secondCarrerEffect = new SecondCareerHolyRuneSubTips();
            this.addChild(this._swallowEffect);
            return;
        }

        public set equiped(arg1: Boolean)
        {
            this._isEquip = arg1;
            if (arg1) 
            {
                if (this._equippedBitmap == null) 
                {
                    this._equippedBitmap = GlobalClass.getBitmap(ImagesConst.Equipped);
                }
                this._equippedBitmap.x = 145;
                this._equippedBitmap.y = 0;
                this.addChild(this._equippedBitmap);
            }
            else 
            {
                DisplayUtil.removeMe(this._equippedBitmap);
            }
            return;
        }

        protected /* override */ resort(arg1: Boolean=true, arg2: number=0): void
        {
            var loc3=0;
            var loc4=0;
            var loc5=0;
            var loc6=null;
            _currentY = 0;
            _needY = 0;
            _nameLabel.htmlText = ItemsUtil.getItemName(_itemData);
            _currentY = _currentY + (_nameLabel.textField.height + 10);
            _needY = _currentY;
            _imageBg.y = _currentY;
            _imageBg.width = 38;
            _imageBg.height = 38;
            _currentY = _currentY + 3;
            _eqItem.itemData = _itemData;
            _eqItem.amount = -1;
            _eqItem.width = 32;
            _eqItem.height = 32;
            _eqItem.x = 12;
            _eqItem.y = _currentY;
            _currentY = _currentY + (_imageBg.height + 6);
            _needLevelLabel.htmlText = getNeedLevelText();
            _needLevelLabel.move(59, _needY);
            _itemLevelTxt.text = Language.getStringByParam(90018, _tItem.itemLevel.toString());
            _itemLevelTxt.y = _needY + 20;
            _itemTypeBindLabel.htmlText = this.getItemTypeBindText() + "  " + ToolTipUtil.getNeedCareerName(_tItem) + "  " + getSex();
            _itemTypeBindLabel.move(9, _currentY);
            _currentY = _currentY + _itemTypeBindLabel.textField.height;
            if (_tItem.category != ECategory._ECategoryJewel) 
            {
                if (_effectTxt && this.contains(_effectTxt)) 
                {
                    this.removeChild(_effectTxt);
                }
            }
            else 
            {
                if (_effectTxt == null) 
                {
                    _effectTxt = ObjCreate.createTextField("", 9, _currentY, 150, 20, this, GlobalStyle.textFormat6);
                    _effectTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
                }
                _effectTxt.text = GameDefConfig.instance.getEJewel(_tItem.type).name + "    +" + _tItem.effect;
                _effectTxt.y = _currentY;
                if (!this.contains(_effectTxt)) 
                {
                    this.addChild(_effectTxt);
                }
                _currentY = _currentY + _effectTxt.height;
            }
            if (!this._isEquip) 
            {
                if (_itemOwnBmp == null) 
                {
                    _itemOwnBmp = new Object /* flash.display.Bitmap */();
                    _itemOwnBmp.x = 140;
                    _itemOwnBmp.y = -10;
                }
                if (ToolTipUtil.isOwnRuneByItemData(itemData)) 
                {
                    _itemOwnBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.EquipOwned);
                }
                else 
                {
                    _itemOwnBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.EquipNotOwned);
                }
                if (_itemOwnBmp && !this.contains(_itemOwnBmp)) 
                {
                    this.addChildAt(_itemOwnBmp, 1);
                }
            }
            var loc1=getItemDescText();
            if (loc1 == "") 
            {
                if (this.contains(_itemDescTextField)) 
                {
                    this.removeChild(_itemDescTextField);
                }
                _sellToSysLabel.text = "";
            }
            else 
            {
                if (ItemsUtil.isVIPCard(_itemData)) 
                {
                    _itemDescTextField.width = 280;
                }
                else 
                {
                    _itemDescTextField.width = 180;
                }
                _itemDescTextField.htmlText = loc1;
                _itemDescTextField.x = 9;
                _itemDescTextField.y = _currentY;
                if (!this.contains(_itemDescTextField)) 
                {
                    this.addChild(_itemDescTextField);
                }
                _currentY = _currentY + _itemDescTextField.height;
            }
            this._swallowEffect.updateData(itemData);
            this._swallowEffect.y = _currentY;
            this._swallowEffect.x = 9;
            _currentY = _currentY + (this._swallowEffect.getHeight() + 6);
            if (Cache.instance.role.careerSecond > 0 && !(itemData.itemInfo.item.career == ECareer._ECareerNo) && !(itemData.itemInfo.item.career == ECareer._ECareerNewPlayer)) 
            {
                loc3 = itemData.itemInfo.item.career;
                loc4 = RuneToolTipUtil.getRuneCareer(loc3);
                if ((loc5 = Cache.instance.role.careerSecond) == loc4) 
                {
                    loc5 = Cache.instance.role.careerBasic;
                }
                if ((loc6 = SecondCareerUtil.getSecondCareerItemData(loc4, loc5, itemData)) == null) 
                {
                    DisplayUtil.removeMe(this._secondCarrerEffect);
                }
                else 
                {
                    this._secondCarrerEffect.updateData(loc6);
                    this._secondCarrerEffect.y = _currentY;
                    this._secondCarrerEffect.x = 9;
                    _currentY = _currentY + (this._secondCarrerEffect.getHeight() + 6);
                    this.addChild(this._secondCarrerEffect);
                }
            }
            else 
            {
                DisplayUtil.removeMe(this._secondCarrerEffect);
            }
            var loc2;
            if ((loc2 = getSellToSysText()) == "") 
            {
                _sellToSysLabel.visible = false;
                _sellToSysLabel.text = "";
            }
            else 
            {
                _sellToSysLabel.visible = true;
                _sellToSysLabel.htmlText = loc2;
                _sellToSysLabel.move(9, _currentY);
                _currentY = _currentY + _sellToSysLabel.textField.height;
            }
            _sendToChatLabel.move(9, _currentY);
            if (_itemData.category == ECategory._ECategoryProp && _itemData.type == EProp._EPropUseSkill) 
            {
                _sendToChatLabel.visible = false;
            }
            else 
            {
                _sendToChatLabel.visible = true;
            }
            _currentY = _currentY + _sendToChatLabel.textField.height;
            if (isShowGas) 
            {
                if (_addGasTxt == null) 
                {
                    _addGasTxt = ObjCreate.createTextField("", 9, _currentY, 150, 20, this, GlobalStyle.textFormat6);
                    _addGasTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
                }
                _addGasTxt.text = Language.getStringByParam(35991, _itemData.gasValue);
            }
            else if (_addGasTxt && this.contains(_addGasTxt)) 
            {
                this.removeChild(_addGasTxt);
            }
            _nameLabel.x = (super.width - _nameLabel.textField.width) / 2;
            return;
        }

        public /* override */ getItemTypeBindText(): string
        {
            var loc6=null;
            var loc7=null;
            var loc1="#ff87dc";
            var loc2="";
            var loc3="";
            var loc4="";
            var loc5=0;
            if (_tItem) 
            {
                if (!(_tItem.category == 0) && !(_tItem.category == 8)) 
                {
                    if (_tItem.category == ECategory._ECategoryRune && _tItem.type == 1) 
                    {
                        loc2 = Language.getString(90286);
                    }
                    else if (_tItem.category == ECategory._ECategoryRune && _tItem.type == 2) 
                    {
                        loc2 = Language.getString(90287);
                    }
                    else if (_tItem.category == ECategory._ECategoryRune && _tItem.type == 3) 
                    {
                        loc2 = Language.getString(80095);
                    }
                    else if (_tItem.category == ECategory._ECategoryRune && _tItem.type == 4) 
                    {
                        loc2 = Language.getString(80096);
                    }
                    else if (loc6 = GameDefConfig.instance.getECategory(_tItem.category)) 
                    {
                        loc2 = loc6.name;
                    }
                }
                loc5 = ItemsUtil.isBind(_itemData) ? 1 : 0;
                if (!(_tItem.bind == 0) || loc5) 
                {
                    if (!loc5) 
                    {
                        loc5 = _tItem.bind;
                    }
                    if (loc7 = GameDefConfig.instance.getEBind(loc5)) 
                    {
                        loc3 = loc7.name;
                    }
                }
                if (ItemsUtil.isPetSkillBook(_itemData)) 
                {
                    if (ItemsUtil.isCommomPetSkillBook(_itemData)) 
                    {
                        loc4 = Language.getString(90023);
                    }
                    else 
                    {
                        loc4 = Language.getString(28084);
                    }
                }
            }
            return HTMLUtil.addColor(loc2 + "  " + loc4 + "  " + loc3, loc1);
        }

        /* internal */ /* var */_effectsContainer: Object /* flash.display.Sprite */;

        /* internal */ /* var */_effects: Array<any>;

        /* internal */ /* var */_swallowEffect: RuneSWallowedEffects;

        /* internal */ /* var */_secondCarrerEffect: SecondCareerHolyRuneSubTips;

        /* internal */ /* var */_equippedBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isEquip: Boolean=false;
    }
